<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of SW_Density</title>
  <meta name="keywords" content="SW_Density">
  <meta name="description" content="SW_Density    Density of sea water">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">utilities</a> &gt; SW_Density.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for utilities&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>SW_Density
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>SW_Density    Density of sea water</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function rho = SW_Density(T,S) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> SW_Density    Density of sea water
=========================================================================
 USAGE:  rho = SW_Density(T,S)

 DESCRIPTION:
   Density of seawater at atmospheric pressure (0.1 MPa) using Eq. (8)
   given by [1] which best fit the data of [2] and [3]. The pure water
   density equation is a best fit to the data of [4]. 
   Values at temperature higher than the normal boiling temperature are
   calculated at the saturation pressure.

 INPUT:  (all must have same dimensions)
   T = temperature [degree C] (ITS-90)
   S = salinity    [g/kg] (reference-composition salinity)

 OUTPUT:
   rho = density   [kg/m^3]

 AUTHOR:  
   Mostafa H. Sharqawy 12-18-2009, MIT (mhamed@mit.edu)

 DISCLAIMER:
   This software is provided &quot;as is&quot; without warranty of any kind.
   See the file sw_copy.m for conditions of use and licence.
 
 VALIDITY: 0 &lt; T &lt; 180 C; 0 &lt; S &lt; 160 g/kg;
 
 ACCURACY: 0.1%
 
 REFERENCES:
   [1] Sharqawy M. H., Lienhard J. H., and Zubair, S. M., Desalination and Water Treatment, 2009.
   [2] Isdale, and Morris, Desalination, 10(4), 329, 1972.
   [3] Millero and Poisson, Deep-Sea Research, 28A (6), 625, 1981
   [4]    IAPWS release on the Thermodynamic properties of ordinary water
   substance, 1996.        
   UPDATED 09-23-2010 modified to now handle matrices and commented out
   range checking.
=========================================================================</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="ST_Dstar.html" class="code" title="function [dstar] = ST_Dstar(d,varargin)">ST_Dstar</a>	Calculate non-dimensional grain size D*</li><li><a href="ST_taucr.html" class="code" title="function [taucr] = ST_taucr(d,varargin)">ST_taucr</a>	Calculate critical shear stress in Pascals</li><li><a href="ST_wset.html" class="code" title="function [wset] = ST_wset(d,varargin)">ST_wset</a>	Calculate settling velocity of particle diameter d (m) in m/s</li><li><a href="SW_Kviscosity.html" class="code" title="function new = SW_Kviscosity(T,S)">SW_Kviscosity</a>	Calculates the kinemtic viscosity [m^2/s] from the dynamic viscosity and</li><li><a href="calc_tauw.html" class="code" title="function [tauw] = calc_tauw(z0,ncfile,writenetcdf)">calc_tauw</a>	DESCRIPTION:</li><li><a href="check_wset.html" class="code" title="function [wset] = ST_wset(d,varargin)">check_wset</a>	Calculate settling velocity of particle diameter d (m) in m/s</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function rho = SW_Density(T,S)</a>
0002 <span class="comment">% SW_Density    Density of sea water</span>
0003 <span class="comment">%=========================================================================</span>
0004 <span class="comment">% USAGE:  rho = SW_Density(T,S)</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% DESCRIPTION:</span>
0007 <span class="comment">%   Density of seawater at atmospheric pressure (0.1 MPa) using Eq. (8)</span>
0008 <span class="comment">%   given by [1] which best fit the data of [2] and [3]. The pure water</span>
0009 <span class="comment">%   density equation is a best fit to the data of [4].</span>
0010 <span class="comment">%   Values at temperature higher than the normal boiling temperature are</span>
0011 <span class="comment">%   calculated at the saturation pressure.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">% INPUT:  (all must have same dimensions)</span>
0014 <span class="comment">%   T = temperature [degree C] (ITS-90)</span>
0015 <span class="comment">%   S = salinity    [g/kg] (reference-composition salinity)</span>
0016 <span class="comment">%</span>
0017 <span class="comment">% OUTPUT:</span>
0018 <span class="comment">%   rho = density   [kg/m^3]</span>
0019 <span class="comment">%</span>
0020 <span class="comment">% AUTHOR:</span>
0021 <span class="comment">%   Mostafa H. Sharqawy 12-18-2009, MIT (mhamed@mit.edu)</span>
0022 <span class="comment">%</span>
0023 <span class="comment">% DISCLAIMER:</span>
0024 <span class="comment">%   This software is provided &quot;as is&quot; without warranty of any kind.</span>
0025 <span class="comment">%   See the file sw_copy.m for conditions of use and licence.</span>
0026 <span class="comment">%</span>
0027 <span class="comment">% VALIDITY: 0 &lt; T &lt; 180 C; 0 &lt; S &lt; 160 g/kg;</span>
0028 <span class="comment">%</span>
0029 <span class="comment">% ACCURACY: 0.1%</span>
0030 <span class="comment">%</span>
0031 <span class="comment">% REFERENCES:</span>
0032 <span class="comment">%   [1] Sharqawy M. H., Lienhard J. H., and Zubair, S. M., Desalination and Water Treatment, 2009.</span>
0033 <span class="comment">%   [2] Isdale, and Morris, Desalination, 10(4), 329, 1972.</span>
0034 <span class="comment">%   [3] Millero and Poisson, Deep-Sea Research, 28A (6), 625, 1981</span>
0035 <span class="comment">%   [4]    IAPWS release on the Thermodynamic properties of ordinary water</span>
0036 <span class="comment">%   substance, 1996.</span>
0037 <span class="comment">%   UPDATED 09-23-2010 modified to now handle matrices and commented out</span>
0038 <span class="comment">%   range checking.</span>
0039 <span class="comment">%=========================================================================</span>
0040 
0041 <span class="comment">%----------------------</span>
0042 <span class="comment">% CHECK INPUT ARGUMENTS</span>
0043 <span class="comment">%----------------------</span>
0044 <span class="keyword">if</span> nargin ~=2
0045     error(<span class="string">'SW_Density.m: Must pass 2 parameters'</span>)
0046 <span class="keyword">end</span>
0047 
0048 <span class="comment">% CHECK S,T dimensions and verify consistent</span>
0049 [ms,ns] = size(S);
0050 [mt,nt] = size(T);
0051 
0052 <span class="comment">% CHECK THAT S &amp; T HAVE SAME SHAPE</span>
0053 <span class="keyword">if</span> (ms~=mt) | (ns~=nt)
0054     error(<span class="string">'check_stp: S &amp; T must have same dimensions'</span>)
0055 <span class="keyword">end</span>
0056 
0057 <span class="comment">% CHECK THAT S &amp; T ARE WITHIN THE FUNCTION RANGE</span>
0058 vectorsize=size(S);
0059 <span class="keyword">for</span> i = 1:vectorsize(1,1)
0060     <span class="keyword">for</span> j = 1:vectorsize(1,2)
0061 <span class="comment">%         if T(i,j)&gt;180 | T(i,j)&lt;0</span>
0062 <span class="comment">%             disp('Temperature is out of range for density function 0 &lt; T &lt; 180 C');</span>
0063 <span class="comment">%         end</span>
0064 <span class="comment">%         if S(i,j)&lt;0 | S(i,j)&gt;160</span>
0065 <span class="comment">%             disp('Salinity is out of range for density function 0 &lt; S &lt; 160 g/kg');</span>
0066 <span class="comment">%         end</span>
0067         
0068         <span class="comment">%------</span>
0069         <span class="comment">% BEGIN</span>
0070         <span class="comment">%------</span>
0071         s(i,j)=S(i,j)/1000;
0072         a1=9.9992293295E+02;a2=2.0341179217E-02;a3=-6.1624591598E-03;a4=2.2614664708E-05;a5=-4.6570659168E-08;
0073         b1=8.0200240891E+02;b2=-2.0005183488E+00;b3=1.6771024982E-02;b4=-3.0600536746E-05;b5=-1.6132224742E-05;
0074         rho_w(i,j) = a1 + a2*T(i,j) + a3*T(i,j)^2 + a4*T(i,j)^3 + a5*T(i,j)^4;
0075         D_rho(i,j) = b1*s(i,j) + b2*s(i,j)*T(i,j) + b3*s(i,j)*T(i,j)^2 + b4*s(i,j)*T(i,j)^3 + b5*s(i,j)^2*T(i,j)^2;
0076         rho(i,j) = rho_w(i,j) + D_rho(i,j);
0077     <span class="keyword">end</span>
0078 <span class="keyword">end</span>;
0079 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 02-Nov-2011 21:58:00 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>